package LearnAlgorithm.f_字符串;

public class b翻转单个字符串 {
	public static void main(String[] args) {
		String string = "Hello World";
		String string2 = "你好世界";
		System.out.println(reverseString(string));
		System.out.println(reverseStringApi(string2));
	}
	
	public static String reverseString(String string) {
		char[] charArr = new char[string.length()];
		for (int i = 0; i < charArr.length; i++) {
			charArr[i] = string.charAt(charArr.length - 1 - i);
		}
		return new String(charArr);
	}
	
	public static String reverseStringApi(String string) {
		StringBuffer stringBuffer = new StringBuffer(string);
		return stringBuffer.reverse().toString();
	}
}
